package com.smscenter.server.core.wechat;

import com.smscenter.server.core.IExecutor;
import com.zeus.base.smscenter.common.constant.SmsConstants;
import com.zeus.base.smscenter.common.constant.WeChatConstants;
import com.zeus.base.smscenter.common.util.KeyUtil;
import com.zeus.base.smscenter.common.util.WebUtils;


import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2016-12-20.
 */
public class WXExecutor implements IExecutor {

	public static void main(String[] args) throws IOException {
		
		WXExecutor w = new WXExecutor();
		Map map = new HashMap();
		map.put("wechatNo", "sxjjsdwl");
		map.put("phone", "18604512986");
		map.put("content", "订单发货喽123!");
		map.put("bizNo", "4383080");
		map.put("url", "www.baidu.com");

		System.out.println(w.excute(map));;
	}
	
    public String excute(Map<String, Object> params) throws IOException {
        String bizNo = (String) params.get("bizNo");//唯一ID
        String phone = (String) params.get("phone");//电话号
        String content = (String) params.get("content");//内容
        String wechatNo	= (String) params.get("wechatNo");//微信公共号
        String url	= (String) params.get("url");//微信公共号
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put("key", KeyUtil.generate());
        requestMap.put("wechatNo",wechatNo);
        requestMap.put("orderNo",bizNo);
        requestMap.put("content",content);
        requestMap.put("phone",phone);
        requestMap.put("url",url);
        String rsp = WebUtils.doPost(WeChatConstants.WX_URL,WebUtils.buildAllQuery(requestMap, SmsConstants.CHARSET_UTF8), SmsConstants.CHARSET_UTF8, 10000, 10000);
        return rsp;
    }
}
